package com.ywk.base.toolClass.rateLimiter;

import com.google.common.util.concurrent.RateLimiter;

/**
 * @Author zbh
 * @Date 2024/10/21
 */
public class RateLimiterExample {

    private RateLimiter rateLimiter=RateLimiter.create(10);

    public void accessResource() {
        if (rateLimiter.tryAcquire()) {
            //处理请求
        } else {
            System.out.println("请求被限流");
        }
    }
}
